<?php

// Model:'Nam' - Database Table: 'Nam' - Năm thực hiện thuế

Class Nam extends Eloquent {

    //Bang trong csdl
    private $nameTable = 'nam';

    //Lay danh sach du lieu
    public function GetList() {
        return DB::table($this->nameTable)
                        ->orderBy("NAM", "DESC")
                        ->get();
    }

    //Lay mot du lieu xac dinh
    public function GetOne($id) {
        return DB::table($this->nameTable)
                        ->select("*")
                        ->where("ID", $id)
                        ->first();
    }

    public function GetCurrentYear() {
        return DB::table($this->nameTable)
                        ->select("*")
                        ->orderBy("NAM", "DESC")
                        ->first();
    }

    //Luu du lieu them moi
    public function SaveIn($data) {
        try{
            return DB::table($this->nameTable)
                    ->insert($data);
        } catch (Exception $ex) {
            return false;
        }
    }

    //Luu du lieu sua doi
    public function StoreIn($data, $id) {
        
    }

    //Xoa du lieu xac dinh
    public function Remove($id) {
        try{
            return DB::table($this->nameTable)
                    ->delete($id);
        } catch (Exception $ex) {
            return false;
        }
    }

}
